|
Creating an event handler
What should be done, if it is necessary to define a new event handler, which does not belong to the basic class? Let us examine it on the example of the “TfrxEditControl” common control: private { new event } FOnChange: TfrxNotifyEvent; procedure DoOnChange(Sender: TObject); ... public ... published property OnChange: TfrxNotifyEvent read FOnChange write FOnChange; ... end; constructor TfrxEditControl.Create(AOwner: TComponent); begin { connect our handler } FEdit.OnChange := DoOnChange; InitControl(FEdit); ... end; procedure TfrxEditControl.DoOnChange(Sender: TObject); begin if Report <> nil then end; It is important to notice that events in FastReport are a procedure declared in the report's script. A string containing its name will be the link to such handler. That is why, for example, unlike the Delphi TNotifyEvent type, which is the method's address, the handler's type in FastReport is a string (the TfrxNotifyEvent type is declared as String [63]). |